const express = require("express");
const db = require("../../utils/db");
const router = express.Router();

router.post('/login',(req,res)=>{
    const {username,password} = req.body
    const sql = `SELECT * FROM admin WHERE user='${username}' AND password='${password}'`
    db.query(sql,(err,data)=>{
        console.log(sql)
        if(err){
            res.send({err,code:1,msg:"请求失败"})
        }else{
            if(data.length>0){
                res.send({code:0,data,msg:'成功'})
            }else{
                res.send({code:1,msg:'账号和密码错误'})
            }
            
        }
    })
})


module.exports = router;